/*
 * @Author: Huangdong
 * @Date: 2022-03-28 15:40:33
 * @LastEditors: minsheng_insurance_agency_zhoucl
 * @LastEditTime: 2023-12-22 11:35:27
 * @FilePath: \01.latest-short-insure\src\utils\filters.js
 * @Description:
 *
 *
 */
const SysTemStatus = [
  {
    value: "0",
    label: "未预收",
  },
  {
    value: "1",
    label: "未承保",
  },
  {
    value: "2",
    label: "拒保",
  },
  {
    value: "3",
    label: "已承保",
  },
  {
    value: "4",
    label: "撤单",
  },
  {
    value: "5",
    label: "犹退",
  },
  {
    value: "6",
    label: "退保",
  },
  {
    value: "7",
    label: "完成",
  }, //(用于表示可以结算佣金)
  {
    value: "8",
    label: "支付成功",
  },
  {
    value: "9",
    label: "支付收费中",
  },
  {
    value: "10",
    label: "支付失败",
  },
  {
    value: "11",
    label: "承保失败",
  },
  {
    value: "12",
    label: "人核中",
  },
  {
    value: "13",
    label: "转人工核保承保中",
  },
  {
    value: "14",
    label: "已回执",
  },
  {
    value: "15",
    label: "承保中",
  },
  {
    value: "16",
    label: "核保失败",
  },
  {
    value: "17",
    label: "待支付",
  },
  {
    value: "18",
    label: "人核（函件待处理）",
  },
  {
    value: "19",
    label: "人核（函件已处理）",
  },
  {
    value: "20",
    label: "核保中",
  },
];
const orderStatusName = (num) => {
  let res = "未预收";
  const target = SysTemStatus.find((item) => item.value == num);
  if (target) {
    res = target.label;
  }
  return res;
};
const orderStatusClass = (num) => {
  if (num > 5) {
    return "success";
  }
  return "danger";
};

const insureYearName = (val, insuYearType) => {
  if (insuYearType === "A") {
    if (val === "106") {
      return "终身";
    } else {
      return "保至" + val + "岁";
    }
  } else if (insuYearType === "D") {
    return val;
  } else {
    if (val === "106") {
      return "终身";
    }
    return val + "年";
  }
};
const payendYearName = (val) => {
  return val === "趸交" ? "趸交" : val + "年交";
};

const riskAmntFormat = (val) => {
  if (val > 10000) {
    return val % 10000 === 0 ? val / 10000 + "万元" : val + "元";
  } else {
    return !val || val === 0 ? "0" : val + "元";
  }
};

/**
 * @Author: ChunLai
 * @Date: 2022-06-17 09:12:08
 * @description: 隐藏手机号中间4位
 * @param {*} phone
 * @return {*}
 */
const tellPhoneFormat = (phone) => {
  phone += "";
  return phone.replace(/(\d{3})\d*(\d{4})/g, "$1***$2");
};

/**
 * @Author: ChunLai
 * @Date: 2022-06-17 08:59:14
 * @description: 身份证号码格式化
 * @param {*} val
 * @param {*} type 格式化类型: s保密中间数字 c分割式
 * @return {*}
 */
const idNumFormat = (val, type = "c") => {
  let res = "";
  if (type === "s") {
    res = val.replace(/\D/g, "").replace(/(\d{6})\d*(\d{4})/g, "$1********$2");
  } else {
    res = val.replace(/\D/g, "").replace(/(\d{6})(\d{8})(?=\d)/g, "$1 $2 ");
  }
  return res;
};

export default {
  orderStatusName,
  orderStatusClass,
  insureYearName,
  payendYearName,
  riskAmntFormat,
  tellPhoneFormat,
  idNumFormat,
};
